﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;

namespace Pointandclick.ScreenManagement
{
    abstract class TwoButtonPopUp : MenuScreen
    {

        #region Properties

        private string title, confirm, cancel;

        /// <summary>
        /// Pop Up title
        /// </summary>
        protected string Title
        {
            get { return title; }
            set { title = value; }
        }

        /// <summary>
        /// Confirm button text
        /// </summary>
        protected string Confirm
        {
            get { return confirm; }
            set { confirm = value; }
        }

        /// <summary>
        /// Cancel button text
        /// </summary>
        protected string Cancel
        {
            get { return cancel; }
            set { cancel = value; }
        }

        #endregion

        /// <summary>
        /// Makes the option list with the confirm and cancel option
        /// </summary>
        protected void MakeOptionsList()
        {
            TextMenuButton confirmButton = new TextMenuButton(confirm, Font);
            TextMenuButton cancelButton = new TextMenuButton(cancel, Font);
            this.Options = new List<MenuElement> { confirmButton, cancelButton };
            DistributeElements(new Rectangle((Manager.Window.ClientBounds.Width - Background.Bounds.Width) / 2,
                (int)(((Manager.Window.ClientBounds.Height - Background.Bounds.Height) / 2 + 0.2 * Background.Bounds.Height)), Background.Bounds.Width, (int)(0.8 * Background.Bounds.Height)));
        }

        /// <summary>
        /// Draws the title and the options
        /// </summary>
        /// <param name="spriteBatch"></param>
        /// <param name="color">Color to tint the sprites. Use Color.White for no tinting</param>
        public override void Draw(SpriteBatch spriteBatch, Color color)
        {
            Vector2 temp = new Vector2((Manager.Window.ClientBounds.Width - Background.Bounds.Width) / 2, (Manager.Window.ClientBounds.Height - Background.Bounds.Height) / 2);
            spriteBatch.Draw(Background, temp, color);
            spriteBatch.DrawString(Font, title, temp + new Vector2((Background.Bounds.Width - Font.MeasureString(title).X) / 2, (int)((0.2 * Background.Bounds.Height - Font.MeasureString(title).Y) / 2)), color);
            base.Draw(spriteBatch, color);
        }
    }
}
